﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package reprise.ui {
    import flash.display.*;
    import flash.events.*;
    import flash.filters.*;
    import flash.geom.*;
    
    import reprise.controls.*;
    import reprise.core.*;
    import reprise.css.*;
    import reprise.css.math.*;
    import reprise.css.propertyparsers.*;
    import reprise.css.transitions.*;
    import reprise.events.*;
    import reprise.ui.layoutmanagers.*;
    import reprise.ui.renderers.*;
    import reprise.utils.*;

    public class UIComponent extends UIObject implements ICSSCalculationContext {

        protected var m_paddingBoxWidth:int = 0
        protected var m_cssId:String = "";
        protected var m_borderBoxHeight:int= 0
        protected var m_oldContentBoxWidth:int;
        protected var m_backgroundDisplay:Sprite;
        protected var m_xmlDefinition:XML;
        protected var m_upperContentDisplay:Sprite;
        protected var m_changedStyleProperties:CSSPropertiesChangeList;
        protected var m_contentBoxWidth:int = 0
        protected var m_positionInFlow:int = 1;
        protected var m_upperContentMask:Sprite;
        protected var m_lowerContentDisplay:Sprite;
        protected var m_selectorPathChanged:Boolean;
        private var m_isRenderedHasChanged:Boolean;
        protected var m_intrinsicHeight:int = -1;
        protected var m_autoFlags:Object;
        protected var m_containingBlock:UIComponent;
        protected var m_layoutManager:ILayoutManager;
        protected var m_dimensionsChanged:Boolean;
        protected var m_lowerContentMask:Sprite;
        protected var m_cssPseudoClasses:String = "";
        private var m_forceChildValidation:Boolean;
        protected var m_specifiedStyles:CSSDeclaration;
        protected var m_dropShadowFilter:DropShadowFilter;
        protected var m_stylesInvalidated:Boolean;
        protected var m_nodeAttributes:Object;
        protected var m_bordersDisplay:Sprite;
        protected var m_borderBoxWidth:int;// = 0
        protected var m_positioningType:String;
        protected var m_backgroundRenderer:ICSSRenderer;
        protected var m_borderRenderer:ICSSRenderer;
        protected var m_positionOffset:Point;
        protected var m_selectorPath:String;
        private var m_transitionsManager:CSSTransitionsManager;
        private var m_oldOuterBoxDimension:Point;
        protected var m_paddingBoxHeight:int;// = 0
        protected var m_frozenContentDisplay:Bitmap;
        protected var m_complexStyles:CSSDeclaration;
        protected var m_vScrollbar:Scrollbar;
        protected var m_specifiedDimensionsChanged:Boolean;
        protected var m_frozenContent:BitmapData;
        protected var m_currentStyles:ComputedStyles;
        protected var m_elementDefaultStyles:CSSDeclaration;
        protected var m_weakStyles:CSSDeclaration;
        private var m_scrollbarsDisplay:Sprite;
        public var m_hScrollbar:Scrollbar;
        protected var m_cssClasses:String = "";
        private var m_oldInFlowStatus:int = -1;
        protected var m_oldContentBoxHeight:int;
        protected var m_intrinsicWidth:int = -1;
        private var m_invalidateStylesAfterValidation:Boolean;
        protected var m_instanceStyles:CSSDeclaration;
        protected var m_contentBoxHeight:int= 0
        protected var m_xmlURL:String = "";
        private var m_explicitContainingBlock:UIComponent;

        protected static const TRANSFORM_MATRIX:Matrix = new Matrix();
        protected static const EDGE_NAMES:Array = ["Top", "Right", "Bottom", "Left"];
        protected static const IDENTITY_MATRIX:Matrix = new Matrix();
        protected static const WIDTH_RELATIVE_PROPERTIES:Array = [["marginTop", false], ["marginBottom", false], ["marginLeft", false], ["marginRight", false], ["paddingTop", false], ["paddingBottom", false], ["paddingLeft", false], ["paddingRight", false], ["left", true], ["right", true]];
        protected static const HEIGHT_RELATIVE_PROPERTIES:Array = [["top", true], ["bottom", true], ["height", true]];
        protected static const DEFAULT_SCROLLBAR_WIDTH:int = 16;
        protected static const OWN_WIDTH_RELATIVE_PROPERTIES:Array = [["borderTopLeftRadius", false], ["borderTopRightRadius", false], ["borderBottomLeftRadius", false], ["borderBottomRightRadius", false]];
        protected static const CHILDREN_INVALIDATING_PROPERTIES:Object = {width:true, height:true};

        public function UIComponent(){
            m_autoFlags = {};
            super();
        }
        public function get borderBoxHeight():int{
            return (m_borderBoxHeight);
        }
        public function get left():Number{
            if (!isNaN(m_currentStyles.left)){
                return (m_currentStyles.left);
            };
            if (!isNaN(m_currentStyles.right)){
                return (((m_containingBlock.calculateContentWidth() - m_currentStyles.right) - m_borderBoxWidth));
            };
            return (0);
        }
        public function get outerWidth():int{
            return (m_borderBoxWidth);
        }
        public function set left(_arg1:Number):void{
            var _local2:Point;
            if (isNaN(_arg1)){
                _arg1 = 0;
            };
            m_currentStyles.left = _arg1;
            m_instanceStyles.setStyle("left", (_arg1 + "px"));
            m_autoFlags.left = false;
            if (!m_positionInFlow){
                _local2 = getPositionRelativeToContext(m_containingBlock);
                _local2.x = (_local2.x - x);
                x = ((_arg1 + m_currentStyles.marginLeft) - _local2.x);
            };
        }
        protected function applyInFlowChildPositions():void{
            m_layoutManager.applyFlowPositions(this, m_children);
            m_intrinsicWidth = m_currentStyles.intrinsicWidth;
            m_intrinsicHeight = m_currentStyles.intrinsicHeight;
        }
        public function get opacity():Number{
            return (m_currentStyles.opacity);
        }
        public function get autoFlags():Object{
            return (m_autoFlags);
        }
        public function get right():Number{
            if (!isNaN(m_currentStyles.left)){
                return ((m_currentStyles.left + m_borderBoxWidth));
            };
            if (!isNaN(m_currentStyles.right)){
                return (m_currentStyles.right);
            };
            return ((0 + m_borderBoxWidth));
        }
        public function set opacity(_arg1:Number):void{
            super.alpha = _arg1;
            m_currentStyles.opacity = _arg1;
            m_instanceStyles.setStyle("opacity", _arg1.toString());
        }
        protected function i18n(_arg1:String, _arg2=null){
            return (m_rootElement.applicationContext().i18n(_arg1, _arg2));
        }
        public function setTitleAttribute(_arg1:String):void{
            if (!m_tooltipData){
                setTooltipData(_arg1);
            };
        }
        public function get bottom():Number{
            if (!isNaN(m_currentStyles.top)){
                return ((m_currentStyles.top + m_borderBoxHeight));
            };
            if (!isNaN(m_currentStyles.bottom)){
                return (m_currentStyles.bottom);
            };
            return ((0 + m_borderBoxHeight));
        }
        protected function horizontalScrollbar_change(_arg1:Event=null):void{
            ((m_lowerContentDisplay) && ((m_lowerContentDisplay.x = -(m_hScrollbar.scrollPosition))));
            ((m_upperContentDisplay) && ((m_upperContentDisplay.x = -(m_hScrollbar.scrollPosition))));
        }
        protected function scrollbar_click(_arg1:Event):void{
            _arg1.stopImmediatePropagation();
            _arg1.stopPropagation();
        }
        public function set right(_arg1:Number):void{
            var _local2:Point;
            if (isNaN(_arg1)){
                _arg1 = 0;
            };
            m_currentStyles.right = _arg1;
            m_instanceStyles.setStyle("right", (_arg1 + "px"));
            m_autoFlags.right = false;
            if (!m_positionInFlow){
                _local2 = getPositionRelativeToContext(m_containingBlock);
                _local2.x = (_local2.x - x);
                x = ((((m_containingBlock.calculateContentWidth() - m_borderBoxWidth) - m_currentStyles.right) - m_currentStyles.marginRight) - _local2.x);
            };
        }
        protected function resolvePropsToValue(_arg1:CSSDeclaration, _arg2:Array, _arg3:Number):void{
            var _local5:String;
            var _local6:CSSProperty;
            var _local7:int;
            var _local4:int = _arg2.length;
            while (_local4--) {
                _local5 = _arg2[_local4][0];
                _local6 = _arg1.getStyle(_local5);
                if (_local6){
                    if (_local6.isRelativeValue()){
                        _local7 = m_currentStyles[_local5];
                        m_currentStyles[_local5] = Math.round(_local6.resolveRelativeValueTo(_arg3, this));
                        if (((!(m_changedStyleProperties[_local5])) && (!((m_currentStyles[_local5] == _local7))))){
                            m_changedStyleProperties.addChange("propName");
                        };
                    };
                    m_autoFlags[_local5] = ((_local6.isAuto()) || (_local6.isWeak()));
                } else {
                    m_autoFlags[_local5] = _arg2[_local4][1];
                    m_currentStyles[_local5] = 0;
                };
            };
        }
        protected function applyBackgroundAndBorders():void{
            var _local1:String;
            var _local2:String;
            if (((((m_currentStyles.backgroundColor) || (m_currentStyles.backgroundImage))) || (((m_currentStyles.backgroundGradientColors) && (m_currentStyles.backgroundGradientType))))){
                _local1 = ((m_currentStyles.backgroundRenderer) || (""));
                if (((!(m_backgroundRenderer)) || (!((m_backgroundRenderer.id() == _local1))))){
                    if (m_backgroundDisplay){
                        m_backgroundRenderer.destroy();
                        removeChild(m_backgroundDisplay);
                    };
                    m_backgroundDisplay = new Sprite();
                    m_backgroundDisplay.name = ("background_" + _local1);
                    m_contentDisplay.addChildAt(m_backgroundDisplay, 0);
                    m_backgroundRenderer = m_rootElement.uiRendererFactory().backgroundRendererById(_local1);
                    m_backgroundRenderer.setDisplay(m_backgroundDisplay);
                };
                m_backgroundDisplay.visible = true;
                m_backgroundDisplay.x = (0 - m_currentStyles.borderLeftWidth);
                m_backgroundDisplay.y = (0 - m_currentStyles.borderTopWidth);
                m_backgroundRenderer.setSize(m_borderBoxWidth, m_borderBoxHeight);
                m_backgroundRenderer.setStyles(m_currentStyles);
                m_backgroundRenderer.setComplexStyles(m_complexStyles);
                m_backgroundRenderer.draw();
                m_backgroundDisplay.blendMode = ((m_currentStyles.backgroundBlendMode) || ("normal"));
            } else {
                if (m_backgroundDisplay){
                    m_backgroundDisplay.visible = false;
                };
            };
            if (((((((m_currentStyles.borderTopStyle) || (m_currentStyles.borderRightStyle))) || (m_currentStyles.borderBottomStyle))) || (m_currentStyles.borderLeftStyle))){
                _local2 = ((m_currentStyles.borderRenderer) || (""));
                if (((!(m_borderRenderer)) || (!((m_borderRenderer.id() == _local2))))){
                    if (m_bordersDisplay){
                        m_borderRenderer.destroy();
                        removeChild(m_bordersDisplay);
                    };
                    m_bordersDisplay = new Sprite();
                    m_bordersDisplay.name = ("border_" + _local2);
                    m_contentDisplay.addChildAt(m_bordersDisplay, (m_upperContentDisplay) ? m_contentDisplay.getChildIndex(m_upperContentDisplay) : m_contentDisplay.numChildren);
                    m_borderRenderer = m_rootElement.uiRendererFactory().borderRendererById(_local2);
                    m_borderRenderer.setDisplay(m_bordersDisplay);
                };
                m_bordersDisplay.visible = true;
                m_bordersDisplay.x = (0 - m_currentStyles.borderLeftWidth);
                m_bordersDisplay.y = (0 - m_currentStyles.borderTopWidth);
                m_borderRenderer.setSize(m_borderBoxWidth, m_borderBoxHeight);
                m_borderRenderer.setStyles(m_currentStyles);
                m_borderRenderer.setComplexStyles(m_complexStyles);
                m_borderRenderer.draw();
            } else {
                if (m_bordersDisplay){
                    m_bordersDisplay.visible = false;
                };
            };
        }
        override public function set height(_arg1:Number):void{
            setStyle("height", (int(_arg1) + "px"));
        }
        public function clientRect():Rectangle{
            return (new Rectangle(x, y, m_borderBoxWidth, m_borderBoxHeight));
        }
        public function get contentBoxWidth():int{
            return (m_contentBoxWidth);
        }
        public function set bottom(_arg1:Number):void{
            var _local2:Point;
            if (isNaN(_arg1)){
                _arg1 = 0;
            };
            m_currentStyles.bottom = _arg1;
            m_instanceStyles.setStyle("bottom", (_arg1 + "px"));
            m_autoFlags.bottom = false;
            if (!m_positionInFlow){
                _local2 = getPositionRelativeToContext(m_containingBlock);
                _local2.y = (_local2.y - y);
                y = ((((m_containingBlock.calculateContentHeight() - m_borderBoxHeight) - m_currentStyles.bottom) - m_currentStyles.marginBottom) - _local2.y);
            };
        }
        public function get contentBoxHeight():int{
            return (m_contentBoxHeight);
        }
        public function setTooltipAttribute(_arg1:String):void{
            setTooltipData(_arg1);
        }
        protected function hookIntoDisplayList():void{
            (m_parentElement as UIComponent).addComponentToDisplayList(this, (((((m_positionInFlow == 1)) && ((m_currentStyles.zIndex < 1)))) || ((m_currentStyles.zIndex < 0))));
        }
        public function get cssID():String{
            return (m_cssId);
        }
        public function setInnerXML(_arg1:XMLList):UIComponent{
            ((m_xmlDefinition) && (m_xmlDefinition.setChildren(_arg1)));
            parseXMLContent(_arg1);
            return (this);
        }
        public function setStyle(_arg1:String, _arg2:String=null):void{
            m_instanceStyles.setStyle(_arg1, _arg2);
            invalidateStyles();
        }
        override protected function preinitialize():void{
            super.preinitialize();
            m_instanceStyles = new CSSDeclaration();
        }
        public function get positionInFlow():int{
            return (m_positionInFlow);
        }
        override protected function addChildToContentDisplay(_arg1:UIObject, _arg2:int):void{
            if (!(_arg1 is UIComponent)){
                super.addChildToContentDisplay(_arg1, _arg2);
            };
        }
        override public function remove(... _args):void{
            if (((m_cssId) && (m_rootElement))){
                m_rootElement.removeElementID(m_cssId);
            };
            super.remove();
        }
        override protected function validateAfterChildren():void{
            if (!m_isRendered){
                return;
            };
            var _local1:int = m_intrinsicWidth;
            var _local2:int = m_intrinsicHeight;
            applyInFlowChildPositions();
            measure();
            if (((m_autoFlags.width) && ((((m_currentStyles.display == "inline")) || (((!(m_positionInFlow)) && (((m_autoFlags.left) || (m_autoFlags.right))))))))){
                if (m_transitionsManager.hasTransitionForStyle("width")){
                    if (((m_weakStyles.hasStyle("width")) && ((m_weakStyles.getStyle("width").specifiedValue() == m_intrinsicWidth)))){
                        m_contentBoxWidth = m_currentStyles.width;
                    } else {
                        m_weakStyles.setStyle("width", (m_intrinsicWidth + "px"), true);
                        m_specifiedStyles.setStyle("width", (m_oldContentBoxWidth + "px"));
                        m_transitionsManager.registerAdjustedStartTimeForProperty(m_rootElement.frameTime(), "width");
                        m_contentBoxWidth = m_oldContentBoxWidth;
                        m_invalidateStylesAfterValidation = true;
                        m_stylesInvalidated = true;
                        invalidate();
                    };
                } else {
                    m_contentBoxWidth = m_intrinsicWidth;
                };
            };
            if (((m_autoFlags.height) && (!((m_intrinsicHeight == -1))))){
                if (m_transitionsManager.hasTransitionForStyle("height")){
                    if (((m_weakStyles.hasStyle("height")) && ((m_weakStyles.getStyle("height").specifiedValue() == m_intrinsicHeight)))){
                        m_contentBoxHeight = m_currentStyles.height;
                    } else {
                        m_weakStyles.setStyle("height", (m_intrinsicHeight + "px"), true);
                        m_specifiedStyles.setStyle("height", (m_oldContentBoxHeight + "px"));
                        m_transitionsManager.registerAdjustedStartTimeForProperty(m_rootElement.frameTime(), "height");
                        m_contentBoxHeight = m_oldContentBoxHeight;
                        m_invalidateStylesAfterValidation = true;
                        m_stylesInvalidated = true;
                        invalidate();
                    };
                } else {
                    m_contentBoxHeight = m_intrinsicHeight;
                };
            };
            m_paddingBoxHeight = ((m_contentBoxHeight + m_currentStyles.paddingTop) + m_currentStyles.paddingBottom);
            m_borderBoxHeight = ((m_paddingBoxHeight + m_currentStyles.borderTopWidth) + m_currentStyles.borderBottomWidth);
            m_paddingBoxWidth = ((m_contentBoxWidth + m_currentStyles.paddingLeft) + m_currentStyles.paddingRight);
            m_borderBoxWidth = ((m_paddingBoxWidth + m_currentStyles.borderLeftWidth) + m_currentStyles.borderRightWidth);
            var _local3:Point = new Point(((m_borderBoxWidth + m_currentStyles.marginLeft) + m_currentStyles.marginRight), ((m_borderBoxHeight + m_currentStyles.collapsedMarginTop) + m_currentStyles.collapsedMarginBottom));
            m_dimensionsChanged = !(((m_oldOuterBoxDimension) && (m_oldOuterBoxDimension.equals(_local3))));
            m_oldOuterBoxDimension = _local3;
            var _local4:Boolean;
            m_contentDisplay.y = (m_positionOffset.y + m_currentStyles.borderTopWidth);
            m_contentDisplay.x = (m_positionOffset.x + m_currentStyles.borderLeftWidth);
            if (((m_dimensionsChanged) || (m_stylesInvalidated))){
                applyBackgroundAndBorders();
                applyOverflowProperty();
                if (((((m_currentStyles.float) || (m_positionInFlow))) && (m_dimensionsChanged))){
                    _local4 = true;
                };
            } else {
                if (((((((!((m_contentBoxHeight == m_oldContentBoxHeight))) || (!((m_contentBoxWidth == m_oldContentBoxWidth))))) || (!((m_intrinsicHeight == _local2))))) || (!((m_intrinsicWidth == _local1))))){
                    applyOverflowProperty();
                };
            };
            if (!(((((m_parentElement is UIComponent)) && (!((m_parentElement == this))))) && (UIComponent(m_parentElement).m_isValidating))){
                if ((((((m_oldInFlowStatus == -1)) || (m_dimensionsChanged))) && (!(m_positionInFlow)))){
                    if (((((m_autoFlags.top) && (m_autoFlags.bottom))) || (((m_autoFlags.left) && (m_autoFlags.right))))){
                        _local4 = true;
                    };
                } else {
                    if (m_oldInFlowStatus != m_positionInFlow){
                        _local4 = true;
                    } else {
                        if (m_isRenderedHasChanged){
                            _local4 = true;
                        } else {
                            if (m_changedStyleProperties["zIndex"]){
                                log(m_cssClasses, m_currentStyles.zIndex);
                                _local4 = true;
                            };
                        };
                    };
                };
                if (((m_parentElement) && (!((m_parentElement == this))))){
                    if (((_local4) && (!(UIComponent(m_parentElement).m_isValidating)))){
                        UIComponent(m_parentElement).validateAfterChildren();
                        return;
                    };
                    if (!UIComponent(m_parentElement).m_isValidating){
                        UIComponent(m_parentElement).applyOutOfFlowChildPositions();
                    };
                } else {
                    applyOutOfFlowChildPositions();
                };
            };
            m_layoutManager.applyDepthSorting(m_lowerContentDisplay, m_upperContentDisplay);
            applyTransform();
        }
        public function set cssPseudoClasses(_arg1:String):void{
            m_cssPseudoClasses = _arg1;
            invalidateStyles();
        }
        public function get intrinsicHeight():int{
            return (m_intrinsicHeight);
        }
        protected function createScrollbar(_arg1:String, _arg2:Boolean=false):Scrollbar{
            if (!m_scrollbarsDisplay){
                m_scrollbarsDisplay = new Sprite();
                m_scrollbarsDisplay.name = "scrollbars_display";
                addChild(m_scrollbarsDisplay);
            };
            var _local3:Scrollbar = new Scrollbar();
            _local3.setOverflowScrollMode(true);
            _local3.setParent(this);
            _local3.overrideContainingBlock(this);
            m_scrollbarsDisplay.addChild(_local3);
            _local3.cssClasses = (_arg1 + "Scrollbar");
            _local3.setStyle("position", "absolute");
            _local3.setStyle("autoHide", "false");
            _local3.setStyle("width", (((m_currentStyles.scrollbarWidth) || (DEFAULT_SCROLLBAR_WIDTH)) + "px"));
            if (_arg1 == Scrollbar.ORIENTATION_HORIZONTAL){
                _local3.rotation = -90;
            };
            if (!_arg2){
                _local3.addEventListener(Event.CHANGE, this[(_arg1 + "Scrollbar_change")]);
            };
            _local3.addEventListener(MouseEvent.CLICK, scrollbar_click);
            (_local3 as UIComponent).validateElement(true, true);
            return (_local3);
        }
        public function get cssTag():String{
            return (m_elementType);
        }
        protected function resolveBindings(_arg1:String){
            var valueParts:Array;
            var i:int;
            var bindingParts:Array;
            var selectorPath:String;
            var propertyParts:Array;
            var text = _arg1;
            var result:* = text;
            valueParts = text.split(/(?<!\\){|(?<!\\)}/);
            if (valueParts.length > 1){
                i = 1;
                while (i < valueParts.length) {
                    bindingParts = valueParts[i].split(/\s*,\s*/);
                    selectorPath = "";
                    if (bindingParts.length == 2){
                        selectorPath = bindingParts.shift();
                    };
                    propertyParts = bindingParts[0].split(/\s*:\s*/);
                    try {
                        valueParts[i] = valueBySelectorProperty.apply(this, [selectorPath].concat(propertyParts));
                    } catch(error:Error) {
                        valueParts[i] = (("{" + valueParts[i]) + "}");
                    };
                    i = (i + 2);
                };
                if ((((((valueParts.length > 3)) || (!((valueParts[0] == ""))))) || (!((valueParts[2] == ""))))){
                    result = valueParts.join("");
                } else {
                    result = valueParts[1];
                };
            };
            return (result);
        }
        public function valueBySelectorProperty(_arg1:String, _arg2:String, ... _args){
            var target:UIComponent;
            var targetProperty:*;
            var selector = _arg1;
            var property = _arg2;
            var rest = _args;
            if (!selector){
                target = this;
            } else {
                target = getElementBySelector(selector);
            };
            try {
                targetProperty = target[property];
            } catch(error:Error) {
                if (target.m_currentStyles[property]){
                    return (target.m_currentStyles[property]);
                };
                throw (error);
            };
            if ((targetProperty is Function)){
                targetProperty = (targetProperty as Function).apply(target, rest);
            };
            return (targetProperty);
        }
        public function get containingBlock():UIComponent{
            return (m_containingBlock);
        }
        public function get cssClasses():String{
            return (m_cssClasses);
        }
        public function get selectorPath():String{
            return (m_selectorPath);
        }
        public function set top(_arg1:Number):void{
            var _local2:Point;
            if (isNaN(_arg1)){
                _arg1 = 0;
            };
            m_currentStyles.top = _arg1;
            m_instanceStyles.setStyle("top", (_arg1 + "px"));
            m_autoFlags.top = false;
            if (!m_positionInFlow){
                _local2 = getPositionRelativeToContext(m_containingBlock);
                _local2.y = (_local2.y - y);
                y = ((_arg1 + m_currentStyles.marginTop) - _local2.y);
            };
        }
        protected function createUpperContentDisplay():void{
            m_upperContentDisplay = new Sprite();
            m_contentDisplay.addChild(m_upperContentDisplay);
            m_upperContentDisplay.name = "upper_content_display";
            m_upperContentDisplay.mouseEnabled = false;
        }
        public function set hScroll(_arg1:Number):void{
            if (!m_hScrollbar){
                return;
            };
            m_hScrollbar.scrollPosition = _arg1;
            ((m_lowerContentDisplay) && ((m_lowerContentDisplay.x = -(m_hScrollbar.scrollPosition))));
            ((m_upperContentDisplay) && ((m_upperContentDisplay.x = -(m_hScrollbar.scrollPosition))));
        }
        public function getElementBySelector(_arg1:String):UIComponent{
            return (getElementsBySelector(_arg1)[0]);
        }
        override public function setTooltipDelay(_arg1:int):void{
            m_instanceStyles.setStyle("tooltipDelay", _arg1.toString());
            m_currentStyles.tooltipDelay = _arg1;
        }
        public function set cssID(_arg1:String):void{
            if (m_cssId){
                m_rootElement.removeElementID(m_cssId);
            };
            ((m_rootElement) && (m_rootElement.registerElementID(_arg1, this)));
            m_cssId = _arg1;
            invalidateStyles();
        }
        override public function set alpha(_arg1:Number):void{
            opacity = _arg1;
        }
        protected function createLowerContentDisplay():void{
            m_lowerContentDisplay = new Sprite();
            m_contentDisplay.addChild(m_lowerContentDisplay);
            m_lowerContentDisplay.name = "lower_content_display";
            m_lowerContentDisplay.mouseEnabled = false;
        }
        protected function applyOutOfFlowChildPositions():void{
            var _local1:UIObject;
            if (!m_isRendered){
                return;
            };
            m_layoutManager.applyAbsolutePositions(this, m_children);
            for each (_local1 in m_children) {
                if (((!((_local1 is UIComponent))) || (!(UIComponent(_local1).isRendered())))){
                } else {
                    UIComponent(_local1).applyOutOfFlowChildPositions();
                };
            };
            super.calculateKeyLoop();
        }
        protected function parseXMLAttributes(_arg1:XML):void{
            var _local2:Object;
            var _local3:XML;
            var _local4:String;
            var _local5:String;
            if (_arg1.nodeKind() == "text"){
                m_elementType = "p";
            } else {
                _local2 = {};
                for each (_local3 in _arg1.@*) {
                    if (_local3.nodeKind() != "text"){
                        _local4 = _local3.localName().toString();
                        _local5 = _local3.toString();
                        _local2[_local4] = _local5;
                        assignValueFromAttribute(_local4, _local5);
                    };
                };
                m_nodeAttributes = _local2;
                m_elementType = _arg1.localName().toString();
            };
        }
        protected function parseXMLDefinition(_arg1:XML, _arg2:String):void{
            m_xmlDefinition = _arg1;
            m_xmlURL = _arg2;
            parseXMLAttributes(_arg1);
            parseXMLContent(_arg1.children());
            invalidateStyles();
        }
        public function getElementsByClassName(_arg1:String):Array{
            var _local5:DisplayObject;
            var _local6:UIComponent;
            var _local7:Array;
            var _local2:Array = [];
            var _local3:int = m_children.length;
            var _local4:int;
            while (_local4 < _local3) {
                _local5 = m_children[_local4];
                if (!(_local5 is UIComponent)){
                } else {
                    _local6 = (_local5 as UIComponent);
                    if (_local6.hasCSSClass(_arg1)){
                        _local2.push(_local6);
                    };
                    _local7 = _local6.getElementsByClassName(_arg1);
                    if (_local7.length){
                        _local2 = _local2.concat(_local7);
                    };
                };
                _local4++;
            };
            return (_local2);
        }
        public function get vScroll():Number{
            if (!m_vScrollbar){
                return (0);
            };
            return (m_vScrollbar.scrollPosition);
        }
        public function setStyleAttribute(_arg1:String):void{
            m_instanceStyles = CSSParsingHelper.parseDeclarationString(_arg1, applicationURL());
        }
        public function addCSSClass(_arg1:String):void{
            if (StringUtil.delimitedStringContainsSubstring(m_cssClasses, _arg1, " ")){
                return;
            };
            m_cssClasses = (m_cssClasses + (" " + _arg1));
            if (m_cssClasses.charAt(0) == " "){
                m_cssClasses = m_cssClasses.substr(1);
            };
            invalidateStyles();
        }
        override public function set rotation(_arg1:Number):void{
            super.rotation = _arg1;
            m_currentStyles.rotation = _arg1;
            m_instanceStyles.setStyle("rotation", _arg1.toString());
        }
        public function setClassAttribute(_arg1:String):void{
            cssClasses = _arg1;
        }
        public function get borderBoxWidth():int{
            return (m_borderBoxWidth);
        }
        protected function addComponentToDisplayList(_arg1:UIComponent, _arg2:Boolean):void{
            if (_arg2){
                ((!(m_lowerContentDisplay)) && (createLowerContentDisplay()));
                ((!((_arg1.parent == m_lowerContentDisplay))) && (m_lowerContentDisplay.addChild(_arg1)));
            } else {
                ((!(m_upperContentDisplay)) && (createUpperContentDisplay()));
                ((!((_arg1.parent == m_upperContentDisplay))) && (m_upperContentDisplay.addChild(_arg1)));
            };
        }
        public function innerWidth():int{
            if (((m_vScrollbar) && (m_vScrollbar.visibility()))){
                return ((m_currentStyles.width - m_vScrollbar.outerWidth));
            };
            return (m_currentStyles.width);
        }
        public function resetStyles():void{
            var _local1:UIComponent;
            m_complexStyles = null;
            m_specifiedStyles = null;
            for each (_local1 in m_children) {
                _local1.resetStyles();
            };
            invalidateStyles();
        }
        override public function setVisibility(_arg1:Boolean):void{
            var _local2:String = (_arg1) ? "visible" : "hidden";
            m_instanceStyles.setStyle("visibility", _local2);
            m_currentStyles.visibility = _local2;
            super.setVisibility(_arg1);
        }
        override protected function validateElement(_arg1:Boolean=false, _arg2:Boolean=false):void{
            if (((!(m_isInvalidated)) && (!(_arg1)))){
                m_changedStyleProperties = new CSSPropertiesChangeList();
                m_selectorPathChanged = false;
                validateChildren();
                return;
            };
            m_rootElement.increaseValidatedElementsCount();
            if (_arg2){
                m_stylesInvalidated = true;
            };
            super.validateElement(_arg1);
        }
        protected function resolveContainingBlock():void{
            var _local1:UIComponent;
            var _local2:UIComponent;
            if (m_explicitContainingBlock){
                m_containingBlock = m_explicitContainingBlock;
            } else {
                _local1 = UIComponent(m_parentElement);
                if (m_positioningType == "fixed"){
                    m_containingBlock = m_rootElement;
                } else {
                    if (m_positioningType == "absolute"){
                        _local2 = _local1;
                        while (((_local2) && ((_local2.m_positioningType == "static")))) {
                            _local2 = _local2.m_containingBlock;
                        };
                        m_containingBlock = _local2;
                    } else {
                        m_containingBlock = _local1;
                    };
                };
            };
        }
        public function addElement(_arg1:String=null, _arg2:UIComponent=null, _arg3:String=null, _arg4:int=-1):UIComponent{
            if (!_arg2){
                _arg2 = new UIComponent();
            };
            if (_arg4 == -1){
                addChild(_arg2);
            } else {
                addChildAt(_arg2, _arg4);
            };
            if (_arg3){
                _arg2.cssID = _arg3;
            };
            if (_arg1){
                _arg2.cssClasses = _arg1;
            };
            return (_arg2);
        }
        function innerHeight():int{
            if (((m_hScrollbar) && (m_hScrollbar.visibility()))){
                return ((m_currentStyles.height - m_hScrollbar.outerWidth));
            };
            return (m_currentStyles.height);
        }
        protected function refreshSelectorPath():void{
            var _local2:String;
            var _local1:String = m_selectorPath;
            if (m_parentElement){
                _local2 = ((m_parentElement as UIComponent).selectorPath + " ");
            } else {
                _local2 = "";
            };
            _local2 = (_local2 + (("@" + m_elementType.toLowerCase()) + "@"));
            if (m_cssId){
                _local2 = (_local2 + (("@#" + m_cssId) + "@"));
            };
            if (m_cssClasses){
                _local2 = (_local2 + (("@." + m_cssClasses.split(" ").join("@.")) + "@"));
            };
            if (m_cssPseudoClasses.length){
                _local2 = (_local2 + (m_cssPseudoClasses.split(" :").join("@:") + "@"));
            };
            if (m_isFirstChild){
                _local2 = (_local2 + "@:first-child@");
            };
            if (m_isLastChild){
                _local2 = (_local2 + "@:last-child@");
            };
            if (_local2 != _local1){
                m_selectorPath = _local2;
                m_selectorPathChanged = true;
                return;
            };
            m_selectorPathChanged = false;
        }
        protected function applyScrollbars():void{
            var vScrollerNeeded:Boolean;
            var hScrollerNeeded:Boolean;
            var oldIntrinsicWidth:int;
            var childWidth:Function = function ():int{
                var _local3:UIComponent;
                var _local4:int;
                var _local1:int;
                var _local2:int = m_children.length;
                while (_local2--) {
                    _local3 = (m_children[_local2] as UIComponent);
                    _local4 = ((_local3.m_currentStyles.position == "absolute")) ? _local3.x : 0;
                    _local1 = Math.max((((_local4 + _local3.m_borderBoxWidth) + _local3.m_currentStyles.marginRight) - m_currentStyles.paddingLeft), _local1);
                };
                return (_local1);
            };
            if ((((m_currentStyles.overflowY == 0)) && ((m_intrinsicHeight > m_currentStyles.height)))){
                if (!m_vScrollbar){
                    m_vScrollbar = createScrollbar(Scrollbar.ORIENTATION_VERTICAL);
                    addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheel_turn);
                };
                m_vScrollbar.setVisibility(true);
                if ((((m_currentStyles.overflowX == "scroll")) || ((m_currentStyles.overflowX == 0)))){
                    validateChildren();
                    applyInFlowChildPositions();
                    m_intrinsicWidth = childWidth();
                };
                vScrollerNeeded = true;
            };
            if (m_currentStyles.overflowY == "scroll"){
                vScrollerNeeded = true;
            };
            if ((((m_currentStyles.overflowX == 0)) && ((m_intrinsicWidth > m_currentStyles.width)))){
                if (!m_hScrollbar){
                    m_hScrollbar = createScrollbar(Scrollbar.ORIENTATION_HORIZONTAL);
                };
                m_hScrollbar.setVisibility(true);
                if (vScrollerNeeded){
                    oldIntrinsicWidth = m_intrinsicWidth;
                    validateChildren();
                    applyInFlowChildPositions();
                    applyOutOfFlowChildPositions();
                    m_intrinsicWidth = oldIntrinsicWidth;
                };
                hScrollerNeeded = true;
            };
            if (m_currentStyles.overflowX == "scroll"){
                hScrollerNeeded = true;
            };
            if (vScrollerNeeded){
                m_vScrollbar.setScrollProperties(innerHeight(), 0, (m_intrinsicHeight - innerHeight()));
                m_vScrollbar.top = 0;
                m_vScrollbar.height = ((innerHeight() + m_currentStyles.paddingTop) + m_currentStyles.paddingBottom);
                m_vScrollbar.left = (((m_currentStyles.width - m_vScrollbar.outerWidth) + m_currentStyles.paddingLeft) + m_currentStyles.paddingRight);
                (m_vScrollbar as UIComponent).validateElement(true, true);
                verticalScrollbar_change();
            } else {
                if (m_vScrollbar){
                    m_vScrollbar.setVisibility(false);
                    vScroll = 0;
                };
            };
            if (hScrollerNeeded){
                m_hScrollbar.setScrollProperties(innerWidth(), 0, (m_intrinsicWidth - innerWidth()));
                m_hScrollbar.top = ((m_currentStyles.height + m_currentStyles.paddingTop) + m_currentStyles.paddingRight);
                m_hScrollbar.height = ((innerWidth() + m_currentStyles.paddingLeft) + m_currentStyles.paddingRight);
                (m_hScrollbar as UIComponent).validateElement(true, true);
                horizontalScrollbar_change();
            } else {
                if (m_hScrollbar){
                    m_hScrollbar.setVisibility(false);
                    hScroll = 0;
                };
            };
        }
        override public function setTooltipRenderer(_arg1:String):void{
            m_instanceStyles.setStyle("tooltipRenderer", _arg1);
            m_currentStyles.tooltipRenderer = _arg1;
        }
        override public function get height():Number{
            return (m_contentBoxHeight);
        }
        function overrideContainingBlock(_arg1:UIComponent):void{
            m_explicitContainingBlock = _arg1;
        }
        override protected function validateChildren():void{
            var _local1:String;
            if (!m_isRendered){
                return;
            };
            m_forceChildValidation = m_selectorPathChanged;
            if (!m_forceChildValidation){
                for (_local1 in m_changedStyleProperties) {
                    if (CHILDREN_INVALIDATING_PROPERTIES[_local1]){
                        m_forceChildValidation = true;
                        break;
                    };
                    if (CSSDeclaration.INHERITABLE_PROPERTIES[_local1]){
                        m_forceChildValidation = true;
                        break;
                    };
                };
            };
            super.validateChildren();
        }
        protected function calculateContentHeight():int{
            return (m_contentBoxHeight);
        }
        public function hasActiveTransitionForStyle(_arg1:String):Boolean{
            return (m_transitionsManager.hasActiveTransitionForStyle(_arg1));
        }
        override public function tooltipDelay():int{
            return (((m_currentStyles.tooltipDelay) || (0)));
        }
        public function get cssPseudoClasses():String{
            return (m_cssPseudoClasses);
        }
        protected function track(_arg1:String):void{
            m_rootElement.applicationContext().track(_arg1);
        }
        public function set cssClasses(_arg1:String):void{
            m_cssClasses = _arg1;
            invalidateStyles();
        }
        override protected function validateBeforeChildren():void{
            var _local3:Boolean;
            m_contentDisplay.transform.matrix = IDENTITY_MATRIX;
            if (m_scrollbarsDisplay){
                m_scrollbarsDisplay.transform.matrix = m_contentDisplay.transform.matrix;
            };
            m_oldInFlowStatus = m_positionInFlow;
            m_oldContentBoxWidth = m_contentBoxWidth;
            m_oldContentBoxHeight = m_contentBoxHeight;
            var _local1:int = m_currentStyles.width;
            var _local2:int = m_currentStyles.height;
            if (m_stylesInvalidated){
                _local3 = m_isRendered;
                calculateStyles();
                if ((m_parentElement is UIComponent)){
                    hookIntoDisplayList();
                };
                if (m_firstDraw){
                    dispatchEvent(new DisplayEvent(DisplayEvent.ADDED_TO_DOCUMENT, true));
                };
                m_isRenderedHasChanged = !((_local3 == m_isRendered));
                if (!m_isRendered){
                    visible = false;
                    if (((((m_parentElement) && (_local3))) && (!(UIComponent(m_parentElement).m_isValidating)))){
                        UIComponent(m_parentElement).validateAfterChildren();
                    };
                    return;
                };
                visible = m_visible;
                if (m_stylesInvalidated){
                    if (m_currentStyles.overflowY == "scroll"){
                        if (!m_vScrollbar){
                            m_vScrollbar = createScrollbar(Scrollbar.ORIENTATION_VERTICAL);
                        } else {
                            m_vScrollbar.setVisibility(true);
                        };
                    };
                    if (m_currentStyles.overflowX == "scroll"){
                        if (!m_hScrollbar){
                            m_hScrollbar = createScrollbar(Scrollbar.ORIENTATION_HORIZONTAL);
                        } else {
                            m_hScrollbar.setVisibility(true);
                        };
                    };
                    applyStyles();
                    if (((!((m_currentStyles.width == _local1))) || (!((m_currentStyles.height == _local2))))){
                        m_specifiedDimensionsChanged = true;
                    };
                };
            };
        }
        public function get top():Number{
            if (!isNaN(m_currentStyles.top)){
                return (m_currentStyles.top);
            };
            if (!isNaN(m_currentStyles.bottom)){
                return (((m_containingBlock.calculateContentHeight() - m_currentStyles.bottom) - m_borderBoxHeight));
            };
            return (0);
        }
        public function get attributes():Object{
            return (m_nodeAttributes);
        }
        public function addCSSPseudoClass(_arg1:String):void{
            if (StringUtil.delimitedStringContainsSubstring(m_cssPseudoClasses, (":" + _arg1), " ")){
                return;
            };
            m_cssPseudoClasses = (m_cssPseudoClasses + (" :" + _arg1));
            if (m_cssPseudoClasses.charAt(0) == " "){
                m_cssPseudoClasses = m_cssPseudoClasses.substr(1);
            };
            invalidateStyles();
        }
        protected function initDefaultStyles():void{
        }
        public function addComponent(_arg1:String=null, _arg2:String=null, _arg3:Class=null, _arg4:int=-1):UIComponent{
            if (!_arg3){
                _arg3 = reprise.ui.UIComponent;
            };
			try{
				var _local5:reprise.ui.UIComponent = new (_arg3);
			}catch(e:Error){
				throw Error(e.toString());
			}
            return (addElement(_arg1, _local5, _arg2, _arg4));
        }
        override protected function calculateKeyLoop():void{
        }
        override public function get alpha():Number{
            return (opacity);
        }
        public function get hScroll():Number{
            if (!m_hScrollbar){
                return (0);
            };
            return (m_hScrollbar.scrollPosition);
        }
        public function hasActiveTransitions():Boolean{
            return (m_transitionsManager.isActive());
        }
        protected function mouseWheel_turn(_arg1:MouseEvent):void{
            if (((_arg1.shiftKey) && (m_hScrollbar))){
                m_hScrollbar.scrollPosition = (m_hScrollbar.scrollPosition - (m_hScrollbar.lineScrollSize * _arg1.delta));
                ((m_lowerContentDisplay) && ((m_lowerContentDisplay.x = -(m_hScrollbar.scrollPosition))));
                ((m_upperContentDisplay) && ((m_upperContentDisplay.x = -(m_hScrollbar.scrollPosition))));
            } else {
                if (((((!(_arg1.shiftKey)) && (m_vScrollbar))) || (((_arg1.shiftKey) && (((!(m_hScrollbar)) || (!(m_hScrollbar.visibility())))))))){
                    m_vScrollbar.scrollPosition = (m_vScrollbar.scrollPosition - (m_vScrollbar.lineScrollSize * _arg1.delta));
                    ((m_lowerContentDisplay) && ((m_lowerContentDisplay.y = -(m_vScrollbar.scrollPosition))));
                    ((m_upperContentDisplay) && ((m_upperContentDisplay.y = -(m_vScrollbar.scrollPosition))));
                };
            };
        }
        protected function calculateContentWidth():int{
            return (m_contentBoxWidth);
        }
        override protected function finishValidation():void{
            super.finishValidation();
            m_dimensionsChanged = false;
            m_specifiedDimensionsChanged = false;
            m_isRenderedHasChanged = false;
            if (m_invalidateStylesAfterValidation){
                m_invalidateStylesAfterValidation = false;
                invalidateStyles();
            } else {
                m_stylesInvalidated = false;
            };
        }
        protected function measure():void{
        }
        protected function preprocessTextNode(_arg1:XML, _arg2:Object=null):XML{
            var _local9:XML;
            var _local3:String = UIRendererFactory.TEXTNODE_TAGS;
            if (_local3.indexOf((_arg1.localName() + ",")) == -1){
                return (_arg1);
            };
            var _local4:XMLList = new XMLList(_arg1);
            var _local5:XML = (_arg1.parent() as XML);
            var _local6:XMLList = (_local5) ? _local5.* : null;
            if (!_local6){
                return (_arg1);
            };
            var _local7:int = (_arg1.childIndex() + 1);
            while (_local7 < XMLList(_local5.*).length()) {
                _local9 = XMLList(_local5.*)[_local7];
                if (_local3.indexOf((_local9.localName() + ",")) == -1){
                    break;
                };
                _local4 = (_local4 + _local9);
                delete _local5.*[_local7];
            };
            XML.ignoreWhitespace = false;
            var _local8:XML = <p/>
            ;
            _local8.setChildren(_local4);
            _local6[_arg1.childIndex()] = _local8;
            XML.ignoreWhitespace = true;
            if (((_arg2) && ((_local8.text().toString().search(/\S/g) == -1)))){
                _arg2.nodeIsEmpty = true;
            };
            return (_local8);
        }
        protected function parseXMLContent(_arg1:XMLList):void{
            var _local4:UIComponent;
            XML.prettyPrinting = false;
            var _local2:XML = _arg1[0];
            var _local3:Object = {nodeIsEmpty:false};
            while (_local2) {
                _local2 = preprocessTextNode(_local2, _local3);
                if (_local3.nodeIsEmpty){
                    _local2 = _local2.parent().children()[(_local2.childIndex() + 1)];
                    _local3.nodeIsEmpty = false;
                } else {
                    _local4 = m_rootElement.uiRendererFactory().rendererByNode(_local2);
                    if (_local4){
                        addChild(_local4);
                        _local4.parseXMLDefinition(_local2, m_xmlURL);
                    } else {
                        log(("f No handler found for node: " + _local2.toXMLString()));
                    };
                    _local2 = _local2.parent().children()[(_local2.childIndex() + 1)];
                };
            };
        }
        private function assignValueFromAttribute(_arg1:String, _arg2:String):void{
            var usedValue:*;
            var attributeSetterName:String;
            var attribute = _arg1;
            var value = _arg2;
            usedValue = resolveBindings(value);
            try {
                attributeSetterName = ((("set" + attribute.charAt(0).toUpperCase()) + attribute.substr(1)) + "Attribute");
                var _local4 = this;
                _local4[attributeSetterName](usedValue);
            } catch(error:Error) {
                try {
                    setValueForKey(attribute, usedValue);
                } catch(error:Error) {
                };
            };
        }
        protected function applyMask():void{
            var _local1:int = ((((m_currentStyles.overflowX == "visible")) || ((m_currentStyles.overflowX == null)))) ? m_borderBoxWidth : ((innerWidth() + m_currentStyles.paddingLeft) + m_currentStyles.paddingRight);
            var _local2:int = ((((m_currentStyles.overflowY == "visible")) || ((m_currentStyles.overflowY == null)))) ? m_borderBoxHeight : ((innerHeight() + m_currentStyles.paddingTop) + m_currentStyles.paddingBottom);
            var _local3:Array = [((m_currentStyles["borderTopLeftRadius"]) || (0)), ((m_currentStyles["borderTopRightRadius"]) || (0)), ((m_currentStyles["borderBottomRightRadius"]) || (0)), ((m_currentStyles["borderBottomLeftRadius"]) || (0))];
            if (m_lowerContentDisplay){
                if (!m_lowerContentMask){
                    m_lowerContentMask = new Sprite();
                    addChild(m_lowerContentMask);
                    m_lowerContentMask.visible = false;
                };
                m_lowerContentMask.x = m_currentStyles.borderLeftWidth;
                m_lowerContentMask.y = m_currentStyles.borderTopWidth;
                m_lowerContentMask.graphics.clear();
                m_lowerContentMask.graphics.beginFill(0xFF00, 50);
                GfxUtil.drawRoundRect(m_lowerContentMask, 0, 0, _local1, _local2, _local3);
                m_lowerContentDisplay.mask = m_lowerContentMask;
            };
            if (m_upperContentDisplay){
                if (!m_upperContentMask){
                    m_upperContentMask = new Sprite();
                    addChild(m_upperContentMask);
                    m_upperContentMask.visible = false;
                };
                m_upperContentMask.x = m_currentStyles.borderLeftWidth;
                m_upperContentMask.y = m_currentStyles.borderTopWidth;
                m_upperContentMask.graphics.clear();
                m_upperContentMask.graphics.beginFill(0xFF00, 50);
                GfxUtil.drawRoundRect(m_upperContentMask, 0, 0, _local1, _local2, _local3);
                m_upperContentDisplay.mask = m_upperContentMask;
            };
        }
        override public function get rotation():Number{
            return (m_currentStyles.rotation);
        }
        protected function verticalScrollbar_change(_arg1:Event=null):void{
            ((m_lowerContentDisplay) && ((m_lowerContentDisplay.y = -(m_vScrollbar.scrollPosition))));
            ((m_upperContentDisplay) && ((m_upperContentDisplay.y = -(m_vScrollbar.scrollPosition))));
        }
        public function get outerHeight():int{
            return (m_borderBoxHeight);
        }
        protected function applyOverflowProperty():void{
            var _local1:Boolean;
            var _local2:Boolean;
            var _local3:* = m_currentStyles.overflowX;
            var _local4:* = m_currentStyles.overflowY;
            if ((((((_local3 == "visible")) || ((_local3 == null)))) || ((_local3 == "hidden")))){
                if (m_hScrollbar){
                    m_hScrollbar.setVisibility(false);
                    hScroll = 0;
                };
                if (_local3 == "hidden"){
                    _local1 = true;
                };
            } else {
                _local2 = true;
                _local1 = _local2;
            };
            if ((((((_local4 == "visible")) || ((_local4 == null)))) || ((_local4 == "hidden")))){
                if (m_vScrollbar){
                    m_vScrollbar.setVisibility(false);
                    vScroll = 0;
                };
                if (_local4 == "hidden"){
                    _local1 = true;
                };
            } else {
                _local2 = true;
                _local1 = _local2;
            };
            if (_local2){
                applyScrollbars();
            };
            if (_local1){
                applyMask();
            } else {
                ((m_lowerContentDisplay) && ((m_lowerContentDisplay.mask = null)));
                ((m_upperContentDisplay) && ((m_upperContentDisplay.mask = null)));
            };
        }
        override protected function initialize():void{
            if (!m_class.basicStyles){
                m_class.basicStyles = new CSSDeclaration();
                m_elementDefaultStyles = m_class.basicStyles;
                initDefaultStyles();
            } else {
                m_elementDefaultStyles = m_class.basicStyles;
            };
            m_transitionsManager = new CSSTransitionsManager(this);
            m_layoutManager = new CSSBoxModelLayoutManager();
            m_currentStyles = new ComputedStyles();
            m_weakStyles = new CSSDeclaration();
            m_stylesInvalidated = true;
            if (m_cssId){
                m_rootElement.registerElementID(m_cssId, this);
            };
            super.initialize();
        }
        override public function setFocus(_arg1:Boolean, _arg2:String):void{
            if (_arg1){
                addCSSPseudoClass("focus");
            } else {
                removeCSSPseudoClass("focus");
            };
        }
        override public function set width(_arg1:Number):void{
            setStyle("width", (int(_arg1) + "px"));
        }
        public function applyTransform():void{
            var _local1:Number;
            var _local2:Number;
            var _local3:Array;
            var _local4:Matrix;
            var _local5:int;
            var _local6:int;
            var _local7:Object;
            var _local8:Array;
            if (m_currentStyles.transform){
                _local1 = (m_borderBoxWidth / 2);
                _local2 = (m_borderBoxHeight / 2);
                if (m_complexStyles.hasStyle("transformOriginX")){
                    _local1 = m_complexStyles.getStyle("transformOriginX").resolveRelativeValueTo(m_borderBoxWidth);
                } else {
                    _local1 = (m_borderBoxWidth / 2);
                };
                if (m_complexStyles.hasStyle("transformOriginY")){
                    _local2 = m_complexStyles.getStyle("transformOriginY").resolveRelativeValueTo(m_borderBoxHeight);
                } else {
                    _local2 = (m_borderBoxHeight / 2);
                };
                _local3 = m_currentStyles.transform;
                _local4 = TRANSFORM_MATRIX;
                _local4.identity();
                _local4.translate(-(_local1), -(_local2));
                _local5 = _local3.length;
                _local6 = _local5;
                while (_local6--) {
                    _local7 = _local3[_local6];
                    _local8 = _local7.parameters;
                    switch (_local7.type){
                        case "translate":
                            _local4.translate(CSSProperty(_local8[0]).resolveRelativeValueTo(m_borderBoxWidth), CSSProperty(_local8[1]).resolveRelativeValueTo(m_borderBoxHeight));
                            break;
                        case "translateX":
                            _local4.translate(CSSProperty(_local8[0]).resolveRelativeValueTo(m_borderBoxWidth), 0);
                            break;
                        case "translateY":
                            _local4.translate(0, CSSProperty(_local8[1]).resolveRelativeValueTo(m_borderBoxHeight));
                            break;
                        case "rotate":
                            _local4.rotate(_local8[0]);
                            break;
                        case "scale":
                            _local4.scale(_local8[0], _local8[1]);
                            break;
                        case "scaleX":
                            _local4.scale(_local8[0], 1);
                            break;
                        case "scaleY":
                            _local4.scale(1, _local8[1]);
                            break;
                        case "skew":
                            _local4.concat(new Matrix(1, _local8[1], _local8[0]));
                            break;
                        case "skewX":
                            _local4.concat(new Matrix(1, 0, _local8[0]));
                            break;
                        case "skewY":
                            _local4.concat(new Matrix(1, _local8[1]));
                            break;
                        case "matrix":
                            _local4.concat(Matrix(_local8[0]));
                            break;
                    };
                };
                _local4.translate(_local1, _local2);
                if (m_positioningType == "relative"){
                    _local4.translate(m_currentStyles.left, m_currentStyles.top);
                };
                m_contentDisplay.transform.matrix = _local4;
                if (m_scrollbarsDisplay){
                    m_scrollbarsDisplay.transform.matrix = _local4;
                };
            };
        }
        protected function resolvePositioningProperties():void{
            if (m_currentStyles.float == "none"){
                m_currentStyles.float = null;
            };
            var _local1:String = (m_positioningType = m_currentStyles.position);
            if (((!(m_currentStyles.float)) && ((((_local1 == "static")) || ((_local1 == "relative")))))){
                m_positionInFlow = 1;
            } else {
                m_positionInFlow = 0;
            };
        }
        public function valueForKey(_arg1:String){
            return (this[_arg1]);
        }
        override protected function validateChild(_arg1:UIObject):void{
            if ((_arg1 is UIComponent)){
                UIComponent(_arg1).validateElement(m_forceChildValidation, m_forceChildValidation);
            } else {
                super.validateChild(_arg1);
            };
        }
        public function get style():ComputedStyles{
            return (m_currentStyles);
        }
        public function getElementsBySelector(_arg1:String):Array{
            var _local3:Array;
            var _local4:UIComponent;
            var _local7:String;
            var _local8:int;
            var _local9:String;
            var _local10:Array;
            var _local11:String;
            var _local12:Array;
            var _local13:Array;
            var _local14:Array;
            var _local15:String;
            var _local16:String;
            var _local2:Array = [];
            var _local5:Array = [];
            var _local6:int = _arg1.lastIndexOf("#");
            if (_local6 != -1){
                _arg1 = _arg1.substr((_local6 + 1));
                _local3 = _arg1.split(" ");
                _local7 = _local3.shift();
                _local7 = ((_local7.split(".")[0] as String).split("[")[0] as String).split(":")[0];
                _local4 = m_rootElement.getElementById(_local7);
                if (!_local4){
                    return (_local2);
                };
                _local5.push(_local4);
            } else {
                _local5.push(this);
                _local3 = _arg1.split(" ");
            };
            while (((_local5.length) && (_local3.length))) {
                _local9 = _local3.shift();
                _local10 = _local9.split("[");
                _local11 = _local10[0];
                if (_local10[1]){
                    _local8 = parseInt(_local10[1]);
                };
                _local12 = _local5;
                _local5 = [];
                _local14 = _local11.split(".");
                _local16 = _local14.shift();
                if (_local16.length){
                    while (_local12.length) {
                        _local4 = _local12.shift();
                        _local13 = _local4.getElementsByTagName(_local16);
                        if (_local13.length){
                            _local5 = _local5.concat(_local13);
                        };
                    };
                } else {
                    _local15 = _local14.shift();
                    while (_local12.length) {
                        _local4 = _local12.shift();
                        _local13 = _local4.getElementsByClassName(_local15);
                        if (_local13.length){
                            _local5 = _local5.concat(_local13);
                        };
                    };
                };
            };
            _local2 = _local5;
            return (_local2);
        }
        public function get intrinsicWidth():int{
            return (m_intrinsicWidth);
        }
        override public function get width():Number{
            return (m_contentBoxWidth);
        }
        public function get paddingBoxHeight():int{
            return (m_paddingBoxHeight);
        }
        public function set vScroll(_arg1:Number):void{
            if (!m_vScrollbar){
                return;
            };
            m_vScrollbar.scrollPosition = _arg1;
            ((m_lowerContentDisplay) && ((m_lowerContentDisplay.y = -(m_vScrollbar.scrollPosition))));
            ((m_upperContentDisplay) && ((m_upperContentDisplay.y = -(m_vScrollbar.scrollPosition))));
        }
        public function removeCSSClass(_arg1:String):void{
            if (!StringUtil.delimitedStringContainsSubstring(m_cssClasses, _arg1, " ")){
                return;
            };
            m_cssClasses = StringUtil.removeSubstringFromDelimitedString(m_cssClasses, _arg1, " ");
            invalidateStyles();
        }
        protected function resolveRelativeStyles(_arg1:CSSDeclaration, _arg2:int=-1, _arg3:int=-1):void{
            var _local5:String;
            var _local6:CSSProperty;
            var _local7:int;
            var _local8:String;
            var _local9:int;
            var _local10:int;
            var _local4 = (m_currentStyles.boxSizing == "border-box");
            if (_arg2 == -1){
                _arg2 = m_containingBlock.innerWidth();
            };
            if (_arg3 == -1){
                _arg3 = m_containingBlock.innerHeight();
            };
            resolvePropsToValue(_arg1, WIDTH_RELATIVE_PROPERTIES, _arg2);
            for each (_local5 in EDGE_NAMES) {
                _local8 = m_currentStyles[(("border" + _local5) + "Style")];
                if (_local8 == "none"){
                    m_currentStyles[(("border" + _local5) + "Width")] = 0;
                };
            };
            _local6 = _arg1.getStyle("width");
            _local7 = m_currentStyles.width;
            if (((!(_local6)) || ((_local6.specifiedValue() == "auto")))){
                m_autoFlags.width = true;
                if (!m_positionInFlow){
                    m_contentBoxWidth = (m_currentStyles.width = ((((((((_arg2 - m_currentStyles.left) - m_currentStyles.right) - m_currentStyles.marginLeft) - m_currentStyles.marginRight) - m_currentStyles.paddingLeft) - m_currentStyles.paddingRight) - m_currentStyles.borderLeftWidth) - m_currentStyles.borderRightWidth));
                } else {
                    m_contentBoxWidth = (m_currentStyles.width = ((((((_arg2 - m_currentStyles.marginLeft) - m_currentStyles.marginRight) - m_currentStyles.paddingLeft) - m_currentStyles.paddingRight) - m_currentStyles.borderLeftWidth) - m_currentStyles.borderRightWidth));
                };
            } else {
                if (_local6.isWeak()){
                    m_autoFlags.width = true;
                } else {
                    m_autoFlags.width = false;
                    if (_local6.isRelativeValue()){
                        _local9 = _arg2;
                        if (m_positioningType == "absolute"){
                            _local9 = (_local9 + (m_containingBlock.m_currentStyles.paddingLeft + m_containingBlock.m_currentStyles.paddingRight));
                        };
                        m_currentStyles.width = _local6.resolveRelativeValueTo(_local9, this);
                    } else {
                        if (_local4){
                            m_currentStyles.width = _local6.specifiedValue();
                        };
                    };
                    if (_local4){
                        m_currentStyles.width = (m_currentStyles.width - (((m_currentStyles.borderLeftWidth + m_currentStyles.paddingLeft) + m_currentStyles.borderRightWidth) + m_currentStyles.paddingRight));
                        if (m_currentStyles.width < 0){
                            m_currentStyles.width = 0;
                        };
                    };
                    m_contentBoxWidth = ((m_currentStyles.width) || (0));
                };
            };
            if (((!(m_changedStyleProperties.width)) && (!((m_currentStyles.width == _local7))))){
                m_changedStyleProperties.addChange("width");
            };
            resolvePropsToValue(_arg1, HEIGHT_RELATIVE_PROPERTIES, _arg3);
            m_contentBoxHeight = m_currentStyles.height;
            if (((_local4) && (!(m_autoFlags.height)))){
                _local10 = _arg1.getStyle("height").resolveRelativeValueTo(_arg3);
                m_contentBoxHeight = (_local10 - (((m_currentStyles.borderTopWidth + m_currentStyles.paddingTop) + m_currentStyles.borderBottomWidth) + m_currentStyles.paddingBottom));
                if (m_contentBoxHeight < 0){
                    m_contentBoxHeight = 0;
                };
                m_currentStyles.height = m_contentBoxHeight;
                if (((!(m_changedStyleProperties.height)) && (!((m_contentBoxHeight == _local10))))){
                    m_changedStyleProperties.addChange("height");
                };
            };
            resolvePropsToValue(_arg1, OWN_WIDTH_RELATIVE_PROPERTIES, (m_contentBoxWidth + m_currentStyles.borderTopWidth));
            m_currentStyles.collapsedMarginTop = m_currentStyles.marginTop;
            m_currentStyles.collapsedMarginBottom = m_currentStyles.marginBottom;
        }
        function setValueForKey(_arg1:String, _arg2):void{
            var setterName:String;
            var key = _arg1;
            var value = _arg2;
            try {
                setterName = (("set" + key.charAt(0).toUpperCase()) + key.substr(1));
                var _local4 = this;
                _local4[setterName](value);
            } catch(error:Error) {
                this[key] = value;
            };
        }
        protected function calculateStyles():void{
            refreshSelectorPath();
            var _local1:CSSDeclaration = new CSSDeclaration();
            var _local2:CSSDeclaration = m_specifiedStyles;
            _local1.mergeCSSDeclaration(m_instanceStyles);
            if (m_rootElement.styleSheet){
                _local1.mergeCSSDeclaration(m_rootElement.styleSheet.getStyleForEscapedSelectorPath(m_selectorPath), false, true);
            };
            if (((!((m_parentElement == this))) && ((m_parentElement is UIComponent)))){
                _local1.mergeCSSDeclaration(UIComponent(m_parentElement).m_complexStyles, true, true);
            };
            _local1.mergeCSSDeclaration(m_elementDefaultStyles, false, true);
            _local1.mergeCSSDeclaration(m_weakStyles, false, true);
            m_changedStyleProperties = _local1.compare(_local2);
            if (((((((!(((m_containingBlock) && (m_containingBlock.m_specifiedDimensionsChanged)))) && (!(m_changedStyleProperties.length)))) && (!(m_transitionsManager.isActive())))) && (!((((this == m_rootElement)) && (DocumentView(this).stageDimensionsChanged)))))){
                m_stylesInvalidated = false;
                return;
            };
            m_specifiedStyles = _local1;
            _local1 = m_transitionsManager.processTransitions(_local2, _local1, m_changedStyleProperties, stage.frameRate, m_rootElement.frameTime());
            m_complexStyles = _local1;
            m_currentStyles.updateValues(_local1, m_changedStyleProperties);
            if (m_transitionsManager.isActive()){
                invalidateStyles();
            };
            m_isRendered = ((!(((_local1.hasStyle("display")) && ((_local1.getStyle("display").specifiedValue() == "none"))))) && (m_rootElement));
            if (!m_isRendered){
                return;
            };
            resolvePositioningProperties();
            resolveContainingBlock();
            resolveRelativeStyles(_local1);
        }
        public function get paddingBoxWidth():int{
            return (m_paddingBoxWidth);
        }
        override public function tooltipRenderer():String{
            return (m_tooltipRenderer);
        }
        public function hasCSSClass(_arg1:String):Boolean{
            return (StringUtil.delimitedStringContainsSubstring(m_cssClasses, _arg1, " "));
        }
        protected function applyStyles():void{
            m_positionOffset = new Point(0, 0);
            if (m_positioningType == "relative"){
                m_positionOffset.x = m_currentStyles.left;
                m_positionOffset.y = m_currentStyles.top;
            };
            m_tabIndex = m_currentStyles.tabIndex;
            m_tooltipRenderer = m_currentStyles.tooltipRenderer;
            m_tooltipDelay = m_currentStyles.tooltipDelay;
            m_contentDisplay.blendMode = m_currentStyles.blendMode;
            if (m_dropShadowFilter != null){
                removeFilter(m_dropShadowFilter);
            };
            if (m_currentStyles.textShadowColor != null){
                m_dropShadowFilter = Filters.dropShadowFilterFromStyleObjectForName(m_currentStyles, "text");
                addFilter(m_dropShadowFilter);
            };
            if ((((m_currentStyles.visibility == "hidden")) && (m_visible))){
                m_visible = (visible = false);
            } else {
                if (((!((m_currentStyles.visibility == "hidden"))) && (!(m_visible)))){
                    m_visible = (visible = true);
                };
            };
            if (m_currentStyles.cursor == "pointer"){
                if (!buttonMode){
                    buttonMode = true;
                    useHandCursor = true;
                };
            } else {
                if (buttonMode){
                    buttonMode = false;
                    useHandCursor = false;
                };
            };
            super.rotation = m_currentStyles.rotation;
            super.alpha = m_currentStyles.opacity;
        }
        public function removeCSSPseudoClass(_arg1:String):void{
            if (!StringUtil.delimitedStringContainsSubstring(m_cssPseudoClasses, (":" + _arg1), " ")){
                return;
            };
            m_cssPseudoClasses = StringUtil.removeSubstringFromDelimitedString(m_cssPseudoClasses, (":" + _arg1), " ");
            invalidateStyles();
        }
        protected function invalidateStyles():void{
            if (m_isValidating){
                m_invalidateStylesAfterValidation = true;
            } else {
                m_stylesInvalidated = true;
                invalidate();
            };
        }
        public function setIdAttribute(_arg1:String):void{
            cssID = _arg1;
        }

    }
}//package reprise.ui 
